var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function() {
        var t = function(e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(t, e) {
                        t.__proto__ = e;
                    }) ||
                function(t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function(e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })(),
    r =
    (this && this.__decorate) ||
    function(t, e, o, n) {
        var r,
            a = arguments.length,
            i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
        else
            for (var s = t.length - 1; s >= 0; s--)
                (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
        return a > 3 && i && Object.defineProperty(e, o, i), i;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = t("Platforms"),
    i = require("./录屏分享"),
    s = cc._decorator,
    c = s.ccclass,
    l =
    (s.property,
        (function(t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            var o;
            return (
                n(e, t),
                (o = e),
                (e.prototype.init = function() {
                    var t = this;
                    (this._start = this.node.getChildByName("start")),
                    this._start.on(cc.Node.EventType.TOUCH_END, function(e) {
                            e.stopPropagation(), t.开始录像();
                        }),
                        (this._end = this.node.getChildByName("end")),
                        this._end.on(cc.Node.EventType.TOUCH_END, function() {
                            t.超过最短录像时间() || a.default.platformCtrl.toast("录屏时间必须大于5秒"), t.停止录像();
                        }),
                        (this._share = this.node.getChildByName("share")),
                        this._share.on(cc.Node.EventType.TOUCH_END, function() {
                            a.default.platformCtrl.gameRecorder_share();
                        }),
                        (this._start.active = !0),
                        (this._end.active = !1),
                        (this._share.active = !1);
                    var e = this._share.getComponent(i.default);
                    (e._onEnable = function() {
                        a.default.platformCtrl.showGameRecorderShareButton(a.default.getDeviceRect(t._share));
                    }),
                    (e._onDisable = function() {
                        a.default.platformCtrl.hideGameRecorderShareButton();
                    }),
                    (this.startTime = 0);
                }),
                (e.prototype.超过最短录像时间 = function() {
                    return this.startTime > 0 && new Date().getTime() - this.startTime > 5e3;
                }),
                (e.prototype.开始录像 = function() {
                    var t = this;
                    this.node.active &&
                        (a.default.platformCtrl.gameRecorder_start(),
                            (this._start.active = !1),
                            (this._end.active = !0),
                            (this._share.active = !1),
                            (this.startTime = new Date().getTime()),
                            a.default.delays.delay({
                                time: 200,
                                action: function() {
                                    a.default.platformCtrl.toast("录屏时间大于200秒自动保存"), t.停止录像();
                                },
                                group: "录屏时间大于200秒自动保存"
                            }));
                }),
                (e.prototype.停止录像 = function() {
                    if (this.超过最短录像时间()) {
                        if (((this.startTime = 0), !this.node.active)) return;
                        a.default.platformCtrl.gameRecorder_stop(),
                            a.default.delays.clear("录屏时间大于200秒自动保存"),
                            (this._start.active = !0),
                            (this._end.active = !1),
                            (this._share.active = !0);
                    } else(this._start.active = !0), (this._end.active = !1), (this._share.active = !1);
                }),
                (e.add = function(t, e, n) {
                    a.default.platformCtrl.显示录屏分享 &&
                        a.default.platformCtrl.gameRecorder_init() &&
                        ((this.instance = a.default.prefabs.instantiate("录屏").getComponent(o)),
                            t.addChild(this.instance.node),
                            (this.instance.node.x = e),
                            (this.instance.node.y = n),
                            this.instance.init());
                }),
                (e.remove = function() {
                    this.instance &&
                        (a.default.delays.clear("录屏时间大于200秒自动保存"),
                            this.instance.node.destroy(),
                            (this.instance = null));
                }),
                (e.stop = function() {
                    this.instance && this.instance.停止录像();
                }),
                (e = o = r([c], e))
            );
        })(cc.Component));
o.default = l;